package com.example.academicsystem.server.controller.student;

import com.example.academicsystem.pojo.dto.StudentGradePageQueryDto;
import com.example.academicsystem.pojo.vo.StudentGradeVo;
import com.example.academicsystem.result.PageResult;
import com.example.academicsystem.result.Result;
import com.example.academicsystem.server.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/student/grade")
@Slf4j
public class StudentGradeController {
    @Autowired
    private StudentService studentService;
    /**
     * 查询全部成绩
    * */
    @GetMapping("/all")
    public Result<List<StudentGradeVo>> studentGradeSelectAll(@RequestParam("id") String studentId){
        log.info("studentGradeSelectAll:"+studentId);
        List<StudentGradeVo> studentGradeVos = studentService.gradeSelectAll(studentId);
        return Result.success(studentGradeVos);
    }

    /**
     * 按页查询
    * */
    @PostMapping("/page")
    public Result<PageResult> studentGradePageQuery(@RequestBody StudentGradePageQueryDto studentGradePageQueryDto){
        log.info("studentGradePageQuery");
        PageResult pageResult=studentService.gradePageQuery(studentGradePageQueryDto);
        return Result.success(pageResult);
    }

    /**
     * 根据课程查询成绩
     *  */
    @PostMapping("/single")
    public Result<PageResult> studentGradeByCourseName(@RequestBody StudentGradePageQueryDto studentGradePageQueryDto){
        log.info("studentGradeByCourseName");
        PageResult pageResult=studentService.studentGradeByCourseName(studentGradePageQueryDto);
        return Result.success(pageResult);
    }


}
